home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15531 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: trib.apple.com!usenet
  2. From: Amir <Amir@bayarea.net>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie question re getting local time
  5. Date: Fri, 05 Apr 1996 17:45:58 -0700
  6. Organization: Apple Computer, Inc., Cupertino, California
  7. Message-ID: <3165BEC6.13EE@bayarea.net>
  8. References: <3165427c.147901903@news.demon.co.uk>
  9. NNTP-Posting-Host: 17.128.203.152
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (Macintosh; I; PPC)
  14.  
  15. I thought I replied this one, but it seems that the reply
  16. is lost, so forgive me if I submitted two replies.
  17.  
  18. Martin McKean wrote:
  19. > Can anyone tell me why the following won't work:
  20. > int iDay;
  21. > LPSYSTEMTIME gLocalTime;
  22. > GetLocalTime(gLocalTime);
  23. > iDay=gLocalTime.wDay;
  24. > As far as I can work out the SYSTEMTIME structure is included, and
  25. > contains the paramater wDay. The compile error I get is:
  26. > error C2231: '._SYSTEMTIME::wDay' : left operand points to 'struct',
  27. > use '->'
  28. > But if I change refs to gLocalTime.wDay to gLocalTime->wDay it
  29. > compiles, but when debugging it stops at the last line above saying
  30. > "Unhandled exception - Access violation".
  31. > All I want is the day of the month; can anyone help?? (MSVC++4)
  32. > Thanks,
  33. > Martin
  34.  
  35. You don't write which system do you use, and how SYSTEMTIME,
  36. LPSYSTEMTIME and GetLocalTime, so I hope my assumptions are right,
  37. and if not prob. someone will correct me.
  38.  
  39. SYSTEMTIME is by what you say the time struct, LPSYSTEMTIME
  40. is prob. defined as a pointer to that struct (LP - Long Pointer ?,
  41. sounds like a PC system :P )
  42.  
  43. GetLocalTime probably accepts a pointer to the SYSTEMTIME 
  44. struct, which you did passed to it, but your pointer doesn't
  45. point to any valid structure (you didn't allocate the memory)
  46.  
  47. This will prob work:
  48.  
  49.  
  50. int iDay;
  51. SYSTEMTIME gLocalTime;
  52. ^^^^^^^^^^
  53. GetLocalTime( & gLocalTime);
  54.              ^^^
  55. iDay=gLocalTime.wDay;
  56.  
  57. Well I hope this helps
  58.  
  59. Amir
  60.